home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 / (Vol 132) Jun 09 2011.iso / Games / baby_chute.swf / scripts / frame_127 / DoAction.as
Encoding:
Text File  |  2011-06-09  |  5.5 KB  |  216 lines

  1. stop();
  2. Mouse.hide();
  3. var i = 0;
  4. var vspeed = 5;
  5. var pointBox = 0;
  6. var smousness = 20;
  7. var cloudplus = 1;
  8. var cloudminus = 3;
  9. var retchLevel = 5;
  10. var retchLevelNum = 0;
  11. var prevRotation = 0;
  12. var prevRotationold = 0;
  13. var gameGoing = true;
  14. _root.kid.gotoAndPlay(1);
  15. floating = function()
  16. {
  17.    _root.kid._y += Number(_root._ymouse - 100 - _root.kid._y) / smousness;
  18.    _root.kid._x += Number(_root._xmouse - _root.kid._x) / smousness;
  19.    _root.kid._rotation = (_root.kid._x - _xmouse) * 0.15;
  20.    if(_root.milklevel._currentframe >= 100)
  21.    {
  22.       if(Math.abs(_root.kid._rotation - _root.prevRotationold) >= 2)
  23.       {
  24.          _root.retchLevelNum += 3;
  25.       }
  26.       else
  27.       {
  28.          _root.retchLevelNum -= 6;
  29.          if(_root.retchLevelNum <= 0)
  30.          {
  31.             _root.retchLevelNum = 0;
  32.          }
  33.       }
  34.       _root.prevRotationold = _root.prevRotation;
  35.       _root.prevRotation = _root.kid._rotation;
  36.       _root.pukelevel.gotoAndStop(retchLevelNum);
  37.       if(_root.retchLevelNum >= 100 && !_root.kid.puke)
  38.       {
  39.          _root.kid.gotoAndPlay("puke");
  40.          _root.retchLevelNum = 0;
  41.          _root.pukelevel.gotoAndStop(1);
  42.          _root.milklevel.gotoAndStop(1);
  43.       }
  44.    }
  45.    balloonMovment();
  46. };
  47. balloonMovment = function()
  48. {
  49.    if(_root.gameGoing)
  50.    {
  51.       _root.balloon._x += 2;
  52.       if(_root.balloon._x >= 560)
  53.       {
  54.          _root.balloon._x = random(300) - 400;
  55.          _root.balloon.balloonNum = random(5) * 100 + 500;
  56.       }
  57.    }
  58. };
  59. cloudEmitter = setInterval(this,"cloudEmitting",1500);
  60. cloudEmitting = function()
  61. {
  62.    i++;
  63.    _root.currentlevel = i;
  64.    whatcomes = random(100);
  65.    if(whatcomes <= 50)
  66.    {
  67.       duplicateMovieClip(cloud,"cloud" + i,16384 + i);
  68.       _root["cloud" + i]._x = random(400) + 50;
  69.       _root["cloud" + i].whole = true;
  70.       _root["cloud" + i].cloud = true;
  71.       _root["cloud" + i]._xscale = random(40) + 80;
  72.       _root["cloud" + i]._yscale = random(40) + 80;
  73.       _root["cloud" + i].onEnterFrame = objectMoving;
  74.    }
  75.    else
  76.    {
  77.       duplicateMovieClip(dummy,"cloud" + i,16384 + i);
  78.       _root["cloud" + i]._x = random(400) + 50;
  79.       _root["cloud" + i].whole = true;
  80.       _root["cloud" + i].cloud = false;
  81.       _root["cloud" + i].gotoAndStop(random(3) + 1);
  82.       _root["cloud" + i].onEnterFrame = objectMoving;
  83.    }
  84. };
  85. objectMoving = function()
  86. {
  87.    this._y -= vspeed;
  88.    if(this.hitTest(_root.kid.hitBox) && this.whole)
  89.    {
  90.       this.whole = false;
  91.       if(this.cloud)
  92.       {
  93.          _root.pointBox -= cloudminus;
  94.          this.gotoAndPlay(2);
  95.          this.points = "-3";
  96.          _root.kid.gotoAndPlay("achoo");
  97.          _root.health.gotoAndStop(_root.health._currentframe + 10);
  98.          if(_root.health._currentframe == 101)
  99.          {
  100.             _root.endGame();
  101.          }
  102.       }
  103.       else
  104.       {
  105.          _root.kid.mouth.gotoAndPlay("smile");
  106.          _root.goodSnd.start();
  107.          this.gotoAndStop(4);
  108.          this.points = "+" + this.pointvalue;
  109.          _root.pointBox += this.pointvalue;
  110.          _root.milklevel.gotoAndStop(_root.milklevel._currentframe + 3 * this.pointvalue);
  111.       }
  112.    }
  113.    else if(this.hitTest(_root.kid.parahitBox) && this.whole)
  114.    {
  115.       this.whole = false;
  116.       this.gotoAndPlay(2);
  117.       if(this.cloud)
  118.       {
  119.          _root.pointBox += cloudplus;
  120.          this.gotoAndPlay(2);
  121.          this.points = "+1";
  122.       }
  123.       else
  124.       {
  125.          _root.alarmSnd.start();
  126.          _root.pointBox -= cloudminus;
  127.          this.gotoAndStop(4);
  128.          this.points = "-3";
  129.          _root.health.gotoAndStop(_root.health._currentframe + 10);
  130.          if(_root.health._currentframe == 101)
  131.          {
  132.             _root.endGame();
  133.          }
  134.       }
  135.    }
  136.    if(this._y <= -50 || _root.gameGoing == false)
  137.    {
  138.       this.onEnterFrame = undefined;
  139.       this.removeMovieClip();
  140.    }
  141. };
  142. endGame = function()
  143. {
  144.    _root.gameGoing = false;
  145.    clearInterval(timePassing);
  146.    clearInterval(cloudEmitter);
  147.    vspeed = 0;
  148.    _root.onEnterFrame = undefined;
  149.    Mouse.show();
  150.    _root.endpanel.duplicateMovieClip("endresult",10000);
  151.    _root.endresult.finalpoints = _root.pointBox;
  152.    if(_root.endresult.finalpoints <= 0)
  153.    {
  154.       this.endresult.grat.gotoAndStop(4);
  155.    }
  156.    else if(_root.endresult.finalpoints <= 50)
  157.    {
  158.       this.endresult.grat.gotoAndStop(3);
  159.    }
  160.    else if(_root.endresult.finalpoints <= 150)
  161.    {
  162.       this.eendresult.grat.gotoAndStop(2);
  163.    }
  164.    else if(_root.endresult.finalpoints <= 1000)
  165.    {
  166.       this.endresult.grat.gotoAndStop(1);
  167.    }
  168.    _root.xyloSnd.start();
  169.    _root.endresult.onEnterFrame = function()
  170.    {
  171.       this._x += (249 - this._x) / 5;
  172.       if(this._x <= 250)
  173.       {
  174.          this.onEnterFrame = undefined;
  175.       }
  176.    };
  177. };
  178. var passedsecs = 0;
  179. TimePassing = function()
  180. {
  181.    passedsecs++;
  182.    if(passedsecs == 40)
  183.    {
  184.       _root.speedupgame();
  185.    }
  186.    else if(passedsecs == 80)
  187.    {
  188.       _root.speedupgame();
  189.    }
  190.    else if(passedsecs == 120)
  191.    {
  192.       _root.endGame();
  193.    }
  194.    leftsecs = 120 - passedsecs;
  195.    minutes = Math.floor(leftsecs / 60);
  196.    seconds = leftsecs - minutes * 60;
  197.    if(seconds <= 9)
  198.    {
  199.       _root.timeBox = minutes + ":0" + seconds;
  200.    }
  201.    else
  202.    {
  203.       _root.timeBox = minutes + ":" + seconds;
  204.    }
  205. };
  206. speedupgame = function()
  207. {
  208.    vspeed++;
  209. };
  210. _root.onEnterFrame = floating;
  211. timePassing = setInterval(this,"TimePassing",1000);
  212. var musicSnd = new Sound();
  213. musicSnd.attachSound("music");
  214. var goodSnd = new Sound();
  215. goodSnd.attachSound("good");
  216.